home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frm8_1_2
- Caption = "Access YOB.TXT"
- ClientHeight = 2910
- ClientLeft = 1305
- ClientTop = 1605
- ClientWidth = 3000
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 2910
- ScaleWidth = 3000
- Begin VB.CommandButton cmdDelete
- Caption = "Delete Above Person from File"
- Height = 495
- Left = 120
- TabIndex = 6
- Top = 2280
- Width = 2775
- End
- Begin VB.CommandButton cmdLookup
- Caption = "Look up Year of Birth"
- Height = 495
- Left = 120
- TabIndex = 5
- Top = 1680
- Width = 2775
- End
- Begin VB.CommandButton cmdAdd
- Caption = "Add Above Person to File"
- Height = 495
- Left = 120
- TabIndex = 4
- Top = 1080
- Width = 2775
- End
- Begin VB.TextBox txtYOB
- Height = 285
- Left = 1320
- TabIndex = 3
- Top = 600
- Width = 1095
- End
- Begin VB.TextBox txtName
- Height = 285
- Left = 720
- TabIndex = 1
- Top = 120
- Width = 1695
- End
- Begin VB.Label lblYOB
- Caption = "Year of Birth"
- Height = 255
- Left = 120
- TabIndex = 2
- Top = 600
- Width = 1095
- End
- Begin VB.Label lblNamr
- Caption = "Name"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 615
- End
- Attribute VB_Name = "frm8_1_2"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub cmdAdd_Click()
- Dim message As String
- 'Add a person's name and year of birth to file
- If (txtName.Text <> "") And (txtYOB.Text <> "") Then
- Open App.Path & "\YOB.TXT" For Append As #1
- Write #1, txtName.Text, Val(txtYOB.Text)
- Close #1
- txtName.Text = ""
- txtYOB.Text = ""
- txtName.SetFocus
- Else
- message = "You must enter a name and year of birth."
- MsgBox message, , "Information Incomplete"
- End If
- End Sub
- Private Sub cmdLookUp_Click()
- Dim message As String
- 'Determine a person's year of birth
- If txtName.Text <> "" Then
- If Dir(App.Path & "\YOB.TXT") <> "" Then
- Call DisplayYearOfBirth
- Else
- message = "Either no file has yet been created or "
- message = message & "the file is not where expected."
- MsgBox message, , "File Not Found"
- End If
- Else
- MsgBox "You must enter a name.", , "Information Incomplete"
- End If
- txtName.SetFocus
- End Sub
- Private Sub cmdDelete_Click()
- Dim message As String
- 'Remove a person from the file
- If txtName.Text <> "" Then
- If Dir(App.Path & "\YOB.TXT") <> "" Then
- Call DeletePerson
- Else
- message = "Either no file has yet been created or "
- message = message & "the file is not where expected."
- MsgBox message, , "File Not Found."
- End If
- Else
- MsgBox "You must enter a name.", , "Information Incomplete"
- End If
- txtName.SetFocus
- End Sub
- Private Sub DeletePerson()
- Dim nom As String, yob As Integer, foundFlag As Boolean
- foundFlag = False
- Open App.Path & "\YOB.TXT" For Input As #1
- Open App.Path & "\TEMP" For Output As #2
- Do While Not EOF(1)
- Input #1, nom, yob
- If nom <> txtName.Text Then
- Write #2, nom, yob
- Else
- foundFlag = True
- End If
- Loop
- Close #1
- Close #2
- Kill App.Path & "\YOB.TXT"
- Name App.Path & "\TEMP" As App.Path & "\YOB.TXT"
- If Not foundFlag Then
- MsgBox "The name was not found.", , ""
- Else
- txtName.Text = ""
- txtYOB.Text = ""
- End If
- End Sub
- Private Sub DisplayYearOfBirth()
- Dim nom As String, yob As Integer
- 'Find the year of birth for the name in txtName
- txtYOB.Text = ""
- Open App.Path & "\YOB.TXT" For Input As #1
- nom = ""
- Do While (nom <> txtName.Text) And (Not EOF(1))
- Input #1, nom, yob
- Loop
- If nom = txtName.Text Then
- txtYOB.Text = Str(yob)
- Else
- MsgBox "Person is not in file.", , ""
- txtName.Text = ""
- End If
- Close #1
- End Sub
-